package kr.hkit.androidcomplete02.ch03;

import kr.hkit.androidcomplete02.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.NumberPicker;
import android.widget.Toast;
import android.widget.NumberPicker.OnValueChangeListener;

public class NumberPickerTest extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.number_picker_test);
		
		NumberPicker picker1 = (NumberPicker) findViewById(R.id.picker1);
		picker1.setMinValue(0);
		picker1.setMaxValue(5);
		picker1.setWrapSelectorWheel(false);
		
		NumberPicker picker2 = (NumberPicker) findViewById(R.id.picker2);
		picker2.setMinValue(0);
		picker2.setMaxValue(20);
		picker2.setValue(10);
		picker2.setOnLongPressUpdateInterval(100);
		
		NumberPicker picker3 = (NumberPicker) findViewById(R.id.picker3);
		picker2.setMinValue(0);
		picker2.setMaxValue(6);
		picker2.setDisplayedValues(new String[]{"일요일","월요일","화요일","수요일",
				"목요일","금요일","토요일"
		});
		
		NumberPicker picker4 = (NumberPicker) findViewById(R.id.picker4);
		picker4.setMinValue(0);
		picker4.setMaxValue(2);
		picker4.setFormatter(mFormatter);
		
		NumberPicker picker5 = (NumberPicker) findViewById(R.id.picker5);
		picker5.setMinValue(100);
		picker5.setMaxValue(200);
		picker5.setOnValueChangedListener(new OnValueChangeListener() {
			
			@Override
			public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
				Toast.makeText(NumberPickerTest.this, "Value : " + newVal, 0).show();
				
			}
		});
	}
	NumberPicker.Formatter mFormatter = new NumberPicker.Formatter() {
	
		
		@Override
		public String format(int value) {
			switch(value){
			case 0:
				return "Zerg";
			case 1:
				return "Terran";
			case 2:
				return "Protoss";
			}
			return null;
		}
	};
}
